package main

import (
	"fmt"
	"sync"
)

func main() {
	var wg sync.WaitGroup
	//wg.Add(1000)
	for i := 0; i < 1000; i++ {
		wg.Add(1)
		// 闭包
		go func() {
			defer wg.Done()
			fmt.Println(i)

		}()

	}
	wg.Wait()

}
